﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;

using QLTTAN.DTO;
namespace QLTTAN.DAL
{
    public class CaHocDAL
    {
        ConnectionData conn;

        public DataTable CaHoc_Load()
        {
            conn = new ConnectionData();
            return conn.GetData("CAHOC_LOAD");
        }

        public int CaHoc_Insert(CaHocDTO CH_DTO)
        {
            conn = new ConnectionData();

            int Nparameter = 3;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];

            name[0] = "Buoi";
            value[0] = CH_DTO.Buoi;
            name[1] = "ThoiGianBatDau";
            value[1] = CH_DTO.ThoiGianBatDau;
            name[2] = "ThoiGianKetThuc";
            value[2] = CH_DTO.ThoiGianKetThuc;

            return conn.UpdateData("CAHOC_INSERT", name, value, Nparameter);
        }

        public int CaHoc_Update(CaHocDTO CH_DTO)
        {
            conn = new ConnectionData();

            int Nparameter = 4;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];

            name[0] = "MaCaHoc";
            value[0] = CH_DTO.MaCaHoc;
            name[1] = "Buoi";
            value[1] = CH_DTO.Buoi;
            name[2] = "ThoiGianBatDau";
            value[2] = CH_DTO.ThoiGianBatDau;
            name[3] = "ThoiGianKetThuc";
            value[3] = CH_DTO.ThoiGianKetThuc;

            return conn.UpdateData("CAHOC_UPDATE", name, value, Nparameter);
        }

        public int CaHoc_Delete(CaHocDTO CH_DTO)
        {
            conn = new ConnectionData();

            int Nparameter = 1;
            string[] name = new string[Nparameter];
            object[] value = new object[Nparameter];

            name[0] = "MaCaHoc";
            value[0] = CH_DTO.MaCaHoc;

            return conn.UpdateData("CAHOC_DELETE", name, value, Nparameter);
        }
    }
}
